using System.ComponentModel.DataAnnotations;

namespace STD.Shared.Domain.Entities;

/// <summary>
/// 基础实体
/// </summary>
public abstract class BaseEntity
{
    /// <summary>
    /// 主键ID
    /// </summary>
    [Key]
    public Guid Id { get; set; }
    
    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreatedAt { get; set; }
    
    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime UpdatedAt { get; set; }
    
    /// <summary>
    /// 是否删除
    /// </summary>
    public bool IsDeleted { get; set; }
    
    /// <summary>
    /// 版本号（用于乐观锁）
    /// </summary>
    public int Version { get; set; }
    
    protected BaseEntity()
    {
        Id = Guid.NewGuid();
        CreatedAt = DateTime.UtcNow;
        UpdatedAt = DateTime.UtcNow;
        IsDeleted = false;
        Version = 1;
    }
} 